Skip to content

fix(runtime): a grant that holds no federation capability is no longer listed list_remote_tables / import_object - #29232

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/project-thread-59tlth
Nov 2, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/project-thread-59tlth

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread
Fixes #28938

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:MCP 的联邦工具 list_remote_tables / import_object 现在只列给真能调用它们的连接:请求持有 manage_platform_settings 或 manage_metadata 才列出,否则 tools/list 不再出现这两件。
  • 为什么改:只授权 metadata:write 的 OAuth 连接拿不到用户的系统能力(只有 actions:execute 才委托),所以以前列出这两件工具却每次调用都 403,管理员也一样。
  • 风险与回滚:没有任何原本能成功的调用变失败;只是"必然 403"变成"工具不在列表里"。回滚即 revert 本 PR。
  • 先看:packages/runtime/src/domains/mcp.ts 的 federation 段(heldFederationCapabilities 与按它决定是否挂上两件工具);mcp-federation-bridge.test.ts 新增的四个用例。
  • 两分钟验证:pnpm --filter @objectstack/runtime exec vitest run src/domains/mcp-federation-bridge.test.ts,预期 8 个用例全绿。
  • 需要你做的:无,席位落地。另有一个产品问题留给你:是否让只带 metadata:write 的连接也能用这两件工具(见报告 open_questions)。

What changes

  • buildMcpBridge (packages/runtime/src/domains/mcp.ts) carries listRemoteTables / importObject only when the request's envelope holds manage_platform_settings (FEDERATION_READ_CAPABILITY) or manage_metadata (FEDERATION_WRITE_CAPABILITY). wireBridgeTools in @objectstack/mcp registers the pair only on a bridge carrying both members, so without them tools/list omits the pair. This is the shape list_actions already has: it hides an action its caller may not run.
  • A new helper, heldFederationCapabilities(ec), is the one read behind both the listing decision and the per-call gate in federationService. The listing and the call therefore cannot disagree.
  • No change to packages/mcp, packages/core or packages/spec. The scope-to-set map (scopesToAgentPermissionSets) and the door's delegation rule (the user's system capabilities reach an agent only under actions:execute) are untouched.

Why

The /mcp door gives an OAuth agent the delegating user's system capabilities only when the grant names actions:execute (packages/core/src/security/assemble-execution-context.ts, systemPermissions). It does not do this through a permission set: metadata:write and actions:execute both map to mcp_agent_restricted. So a metadata:write-only grant holds systemPermissions: [], and both federation calls always answered 403 PERMISSION_DENIED. That held even for an administrator who holds both capabilities, yet the grant was listed both tools.

The card's other route was to judge the human's own capability under metadata:write. That route was measured and not taken, because it would let a grant do more than the published consent text says. The consent text for metadata:write (MCP_OAUTH_SCOPE_CONSENT_COPY, packages/spec/src/ai/mcp.zod.ts) is: "Build and change this app's metadata as drafts, within your own permissions — a person publishes them". import_object saves a live object at once, not a draft, and list_remote_tables reads a live remote schema. Neither is what that sentence promises. Whether metadata:write alone should carry them is the maintainer's call, and it is raised in the report.

Tests

packages/runtime/src/domains/mcp-federation-bridge.test.ts gains four cases. Each envelope is resolved by the real /mcp door (resolveExecutionContext with an OAuth token), not written by hand. The delegating user's set carries both federation capabilities unless stated otherwise:

  1. metadata:write only, administrator: the envelope measures systemPermissions: [], the bridge carries neither member, and the service is never looked up.
  2. metadata:write + actions:execute, same administrator: both members are present, and both calls reach the service.
  3. metadata:write + actions:execute, user holding only manage_metadata: the pair is kept, and list_remote_tables still refuses code: PERMISSION_DENIED, status: 403.
  4. metadata:write + actions:execute, user holding neither capability: neither member.

No existing test was edited.

Acceptance notes

  • For a grant that holds no federation capability, a tools/call on either tool now gets the SDK's unknown-tool answer instead of the 403 envelope. This is the same answer create_record gets without data:write. No call that succeeded before fails now.
  • API keys and sessions are still not served the pair. That gate is grantsAuthoringTools in @objectstack/mcp, which is unchanged, and its pin was ablation-verified below.
  • The MCP dogfood suite has no federation case, so none was added.

Verification

Head: 2a88bf5b9 (merge of origin/main at dedc35051).

Red first on the main code (test commit bf746d0, fix not applied)
× a metadata:write-only grant for an administrator carries neither member: no call of it could pass
× a delegating user holding neither capability is carried neither member
AssertionError: expected 'function' to be 'undefined' // Object.is equality
Tests  2 failed | 6 passed (8)

A one-off probe on the same main code, deleted afterwards, measured the card's symptom: a metadata:write-only administrator gets list PERMISSION_DENIED 403 | import PERMISSION_DENIED 403.

Green and package suites
  • vitest run src/domains/mcp-federation-bridge.test.ts: 8/8 passed.
  • pnpm --filter @objectstack/runtime test (pre-merge head 7de225b + changeset): Test Files 514 passed (514), Tests 8322 passed | 19 skipped. VERDICT command-exit 0.
  • pnpm --filter @objectstack/runtime typecheck: VERDICT command-exit 0.
  • eslint --no-inline-config on the two touched source files: exit 0.
  • After merging origin/main and rebuilding the runtime closure: vitest run src/domains/mcp-federation-bridge.test.ts src/security/resolve-execution-context.test.ts 48/48 passed; pnpm --filter @objectstack/runtime typecheck VERDICT command-exit 0.
Ablations (scripts/ablation-replace.mjs; mutation landed and was restored to the HEAD blob each time)
  1. Always carry the pair (...(heldFederationCapabilities(ec).length > 0 → ...(true): cases 1 and 4 fail, expected 'function' to be 'undefined'. 2 failed | 6 passed.
  2. Drop the per-call gate (if (!heldFederationCapabilities(ec).includes(required)) { → if (false) {): case 3 and the existing "refuses 403 without the capability" pin fail. 2 failed | 6 passed.
  3. Serve keys and sessions (grantsAuthoringTools: Array.isArray(grantedScopes) && → !Array.isArray(grantedScopes) ||, in packages/mcp): "registers neither for a key or a session…" and the skill-parity pin fail. 2 failed | 7 passed.
Derived gates (dispatch-gates --commands, 60 families, on head 2a88bf5)

On the merged head all 60 exited 0. --ran reconciliation, with every exit code recorded: 60 derived, 60 run, 0 NOT-MEASURED, 0 UNRUN.

On the pre-merge head, two families had first exited 3 (PREREQUISITE NOT MET). check:dual-build-cjs-loads lacked dist/ for packages outside the runtime closure. check-plugin-teardown-shape --self-test was missing its pinned fixture commit in the shallow clone, and git fetch of that commit fixed it. Both are green in the run above.


Generated by Claude Code

…nvelope that can call it (red)

Claude-Session: https://claude.ai/code/session_01ADHkmR3xfgrGdYxj32A5PZ
Co-authored-by: Claude <noreply@anthropic.com>
…r listed list_remote_tables / import_object

The /mcp door hands an OAuth agent the delegating user's system capabilities
only under actions:execute, so a metadata:write-only grant holds none and
every call of the federation pair answered 403 — for an administrator too.
The bridge now carries the pair only for an envelope holding one of the two
capabilities, read by the same helper the per-call gate reads.

Claude-Session: https://claude.ai/code/session_01ADHkmR3xfgrGdYxj32A5PZ
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/runtime, touching 3 documentable anchor(s).

1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/permissions/authorization.mdx (via buildMcpBridge (symbol, a top-level function))
What this run could not see
  • the SDK route bridge reached 60 of 216 client-bound route-ledger rows — the other 156 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 156: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 101 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 28 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 45e9b2f14c91f76683296cd33bb1b477cbaef1bb → packageMentionDocs.

Which tree this was computed on

This run read content/docs from b89017cc32fd8ec531fa78b0e4af67739fa94857 — the merge of head 2a88bf5b9049abcf09ca4646c68b810ba8abd7f3 into base 45e9b2f14c91f76683296cd33bb1b477cbaef1bb, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin b89017cc32fd8ec531fa78b0e4af67739fa94857 && git checkout b89017cc32fd8ec531fa78b0e4af67739fa94857
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 45e9b2f14c91f76683296cd33bb1b477cbaef1bb 2a88bf5b9049abcf09ca4646c68b810ba8abd7f3 && git checkout -B drift-repro 45e9b2f14c91f76683296cd33bb1b477cbaef1bb && git merge --no-ff 2a88bf5b9049abcf09ca4646c68b810ba8abd7f3

node scripts/docs-audit/affected-docs.mjs --json 45e9b2f14c91f76683296cd33bb1b477cbaef1bb

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 45e9b2f14c91f76683296cd33bb1b477cbaef1bb → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#2 · os-steve · session_01ADHkmQxwoGb5fSnrFkpxmt

席位核对

ACCEPT · domain:server seat 2 · os-steve · session_01ADHkmQxwoGb5fSnrFkpxmt · 2026-11-02T10:02Z · head 2a88bf5b · claimed by seat 2 on #28938 (comment 6572581612)

The maintainer's words for this seat, verbatim: 「接手所有开发,包括跟进之前未完成的开发落地。」

  1. Shape: a draft against main, first line Fixes #28938, Clause-②: no and Metadata-protocol: none at line start. check-governed-merges --pr 29232: NOT governed. Three files, +158 / -6, all in packages/runtime. Nothing changed in packages/spec, packages/core or packages/mcp, which is what the order asked for.
  2. Route, read against the order: the order said fix it on the runtime side, and any grant-widening beyond the consent text needs a maintainer decision first. The dev measured on main that a metadata:write-only grant holds systemPermissions: [], because system capabilities reach an agent only under actions:execute. So both federation calls answered 403 for every user, administrators included. The fix lists the pair only when the envelope holds manage_platform_settings or manage_metadata. It reads that through one helper, heldFederationCapabilities, which the per-call gate also reads, so the listing and the call cannot disagree. No call that succeeded before fails now; a call that could only 403 is no longer listed, the same shape list_actions and create_record already have. Not a widening: the route that judged the human's own capability under metadata:write was measured and not taken, because import_object saves live while the published consent text promises drafts.
  3. Evidence: red first on main (2 of 8), then 8 of 8. Envelopes are resolved by the real /mcp door, not written by hand. Three ablations, each red and restored: the listing predicate, the per-call 403 gate, and the key/session scope gate. Runtime full suite 514 of 514 files, typecheck green, and green again after the main merge. Gates: 60 derived, 60 run at exit 0.
  4. Gates on this head at ACCEPT time: 12 success, 13 skipped, 0 red, 20 still running. Auto-merge waits for them, and the merge queue re-runs CI against current main.
  5. Open question (whether metadata:write alone should carry the federation pair): this PR keeps today's boundary, and only the maintainer can widen it. The seat records it for him; it does not block this landing, which changes no grant.
  6. Serial: none. No other open claim names packages/runtime/src/domains/mcp.ts. Landing: pr_ready + automerge_enable through the relay.

Generated by Claude Code

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 2, 2026 10:03
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge November 2, 2026 10:03
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

⛔ merge queue 构建失败 — 先分诊,再决定要不要重排

队列构建 41431624287 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集),
所以失败的测试可能在本 PR 没碰过的包里 —— 那不是重排能修的。每次盲目重排都会让排在后面的所有 PR 重建一轮。

分类:failure —— 按下面的日志分诊。

失败的 job(日志抽取,best effort):

  • Test Core (6/8) — 失败步骤: Run this shard's tests

    @objectstack/cli:test:  FAIL   unit  test/validate-build-gate-parity.test.ts > os validate is the read-only superset of os build (#3782, #4409) > the command sources use no call shape this scan cannot
      ↳ 失败原因: @objectstack/cli:test: Error: Test timed out in 5000ms.
    

↳ 失败原因 是判读的关键:超时(Test timed out in … / Hook timed out in …)多半是负载/时序,不是本 PR 的回归;
断言(AssertionError: …)才指向真实的行为改变。两者的 FAIL 行长得一模一样,只有这一行能区分。

⚠️ 断言这一侧有一类例外,判据是断言在测什么,不是它是不是 AssertionError。 断言的对象是产品行为(一个值、一个形状、一次拒收)⇒ 照上面读:真实的行为改变,去查,⛔ 不要重排掉;
断言的对象是这次实验自身的有效性前提(跑完的耗时、负载下的先后、任何只在时间预算内才成立的条件)⇒ 它跟超时是同一类,同样对负载敏感,重排一次是合法的判别手段。
识别是机械的:断言的消息或它比较的值本身点名了一段时长、一个时间戳、一个耗时计数。实测过的一对 —— AssertionError: SecurityPlugin.init() ran: expected false to be true 测的是产品行为(真回归);
AssertionError: this run took over a second, so second-precision stamps could have differed too: expected 1006 to be less than 1000 测的是实验前提:它守护的那条不变式当时是绿的,同一个 head 原样重排一次即成功。
穿着 AssertionError 外衣的时间测量,仍然是时间测量。(⛔ 这只改「怎么读一次红」,不改「哪些测试可以重排」——后者由别处管。)

跨 PR 相同签名(24h,按失败测试文件聚合):

  • test/validate-build-gate-parity.test.ts — 24h 窗口内只有本 PR 撞到过,暂不汇总(再有一个不同 PR 撞到就会自动开汇总 issue)。
  • ⚠️ 24h 评论账本没读完(超过 5 页仍未读到窗口尽头),所以上面的「不同 PR 数」是下界,不是全量。

历史信号:

  • 本 PR 过去 24h 无队列失败记录(首次)。
  • 过去 24h 队列共有 1 个失败构建(不含本次)。

分诊清单:

  1. 失败测试在本 PR 改动的包里 → 真回归,修 PR。
  2. 失败测试与本 PR 无关 → 看上面的「跨 PR 相同签名」;已有汇总 issue ⇒ flaky/环境问题实锤,去那张 issue 上谈,修好前重排只会再烧一轮全队列。
  3. 两者都不是 → 可能与同组 PR 语义冲突;等前面的 PR 落地或失败出队后再重排一次即可,不要连续重排。

Generated by Claude Code · merge-queue-triage workflow (#4859)

@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 2, 2026
Merged via the queue into main with commit d9885f5 Nov 2, 2026
49 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-59tlth branch November 2, 2026 11:56
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#2 · os-steve · session_01ADHkmQxwoGb5fSnrFkpxmt

Landing record · PR #29232

domain:server seat 2 · session_01ADHkmQxwoGb5fSnrFkpxmt · 2026-11-02T12:07Z · card #28938

Reading Probe Result
Merged PR #29232 state merged, merge commit d9885f5d5d
On main git merge-base --is-ancestor d9885f5d5d origin/main yes
Queue refs git ls-remote origin refs/heads/gh-readonly-queue/* matching 29232 0
Content git grep -c heldFederationCapabilities origin/main -- packages/runtime/src/domains/mcp.ts present

Release: ships patch for runtime at the next release.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

1 participant